package com.smart.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smart.model.domain.ManageTempUserRegistrationDO;
import com.smart.model.request.ManageTempUserRegistrationRequest;
import com.smart.model.vo.ManageTempUserRegistrationVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author zyh
 */
@Repository
public interface ManageTempUserRegistrationMapper extends BaseMapper<ManageTempUserRegistrationDO> {
    ManageTempUserRegistrationDO selectDOById(Long id);
    List<ManageTempUserRegistrationDO> selectDOList(ManageTempUserRegistrationDO manageTempUserRegistration);
    int insertManageTempUserRegistration(ManageTempUserRegistrationDO manageTempUserRegistration);
    int batchInsertManageTempUserRegistration(List<ManageTempUserRegistrationDO> manageTempUserRegistrationDOList);
    int updateManageTempUserRegistration(ManageTempUserRegistrationDO manageTempUserRegistration);
    int deleteById(Long id);
    int deleteByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from manage_temp_user_registration",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") ManageTempUserRegistrationRequest param);
    @Select({"<script>",
            "   select * from manage_temp_user_registration",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<ManageTempUserRegistrationDO> pageQuery(@Param("param") ManageTempUserRegistrationRequest param, @Param("limit") int limit, @Param("offset") long offset);

    List<Map<String,Object>> selectByPersonInfo(@Param("personInfo") String personInfo, @Param("list") List<Long> projectIds);

    List<ManageTempUserRegistrationDO> selectByPhoneAndName(@Param("userPhone") String userPhone,@Param("userName")String userName,@Param("projectId") Long projectId);

    List<ManageTempUserRegistrationDO> selectByProject(ManageTempUserRegistrationRequest request);

    List<ManageTempUserRegistrationDO> selectByPhoneOrName(ManageTempUserRegistrationRequest request);

    List<ManageTempUserRegistrationDO> selectByPhone(@Param("userPhone") String userPhone, @Param("projectId") Long projectId);
}
